<form class="form-horizontal span6" id="account-edit" method="post">
	<fieldset>
		<legend>Thông tin đọc giả</legend>
		<div class="control-group">
			<label class="control-label" for="Name">Họ tên</label>
			<div class="controls">
				<input type="text" class="input-xlarge" id="Name" name="Name" value="<?php echo $this->reader['Name']; ?>">
				<!--<p class="help-block">Supporting help text</p>-->
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="Email">Email</label>
			<div class="controls">
				<input type="text" class="input-xlarge" id="Email" name="Email" value="<?php echo $this->reader['Email']; ?>">
				<!--<p class="help-block">Supporting help text</p>-->
			</div>
		</div>		
		<div class="control-group">
			<label class="control-label" for="Password">Tạo mật khẩu mới</label>
			<div class="controls">
				<input type="password" class="input-xlarge" id="Password" name="Password">
				<p class="help-block">Mật khẩu phải từ 6 ký tự trở lên</p>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="PasswordConfirm">Nhập lại mật khẩu</label>
			<div class="controls">
				<input type="password" class="input-xlarge" id="PasswordConfirm" name="PasswordConfirm">
				<!--<p class="help-block">Supporting help text</p>-->
			</div>
		</div>		
		<div class="control-group">
			<label class="control-label">Ngày sinh</label>
			<div class="controls">
			<select name="day" class="input-small">
			    <option value="0">Ngày</option>
				<?php for($d = 1; $d <= 31; $d++) { ?>
				    <option value="<?php echo $d; ?>"<?php if($d == $this->reader['day']) echo ' selected'; ?>><?php echo $d; ?></option>
				<?php } ?>
			</select>
			<select name="month" class="input-small">
			    <option value="0">Tháng</option>
				<?php for($m = 1; $m <= 12; $m++) { ?>
				    <option value="<?php echo $m; ?>"<?php if($m == $this->reader['month']) echo ' selected'; ?>><?php echo $m; ?></option>
				<?php } ?>
			</select>							
			<select name="year" class="input-small">
			    <option value="0">Năm</option>
				<?php $ty = date('Y'); for($y = $ty; $y >= $ty-100; $y--) { ?>
				    <option value="<?php echo $y; ?>"<?php if($y == $this->reader['year']) echo ' selected'; ?>><?php echo $y; ?></option>
				<?php } ?>
			</select>														
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="IDNo">Số CMND</label>
			<div class="controls">
				<input type="text" class="input-xlarge" id="IDNo" name="IDNo" value="<?php echo $this->reader['IDNo']; ?>">
				<!--<p class="help-block">Supporting help text</p>-->
			</div>
		</div>
		<div class="form-actions">
			<button type="submit" class="btn btn-primary">Chỉnh sửa thông tin đọc giả</button>
			<a class="btn" href="javascript: window.location = '<?php echo $this->config->base_path; ?>/librarian/reader'">Huỷ bỏ</a>
			<input type="hidden" name="AccountID" value="<?php echo $this->reader['AccountID']; ?>" />
			<input type="hidden" name="action" value="account" />			
		</div>
	</fieldset>
</form>
<form class="form-horizontal span5" id="card-edit" method="post">
	<fieldset>
		<legend>Thông tin thẻ</legend>
		<?php if (!$this->reader['CardID']) { ?>
                <div class="control-group">			
			<div class="controls" style="margin: 0px">			
				Đọc giả chưa có thẻ thư viện. <a href="javascript:;" class="btn" onclick="$('#card-form').removeClass('hide'); $('[name=CreateCard]').val(1)">Tạo thẻ thư viện</a> / <a href="javascript:;" onclick="$('#card-form').addClass('hide'); $('[name=CreateCard]').val(0)">Huỷ bỏ</a>				
			</div>
		</div>
		<?php } ?>
		<input type="hidden" name="CardID" value="<?php echo $this->reader['CardID']; ?>" />
		<input type="hidden" name="AccountID" value="<?php echo $this->reader['AccountID']; ?>" />		
		<div class="control-group<?php if (!$this->reader['CardID']) echo ' hide'; ?>" id="card-form">
    		<div class="control-group">
    			<label class="control-label" for="CreateDate">Hạn sử dụng từ ngày</label>
    			<div class="controls">
                            <input type="text" data-datepicker class="input-xlarge" id="CreateDate" name="CreateDate" value="<?php if ($this->reader['CardCreateDate']) echo date('d/m/Y', $this->reader['CardCreateDate']); ?>">    				
    				<!--<p class="help-block">Supporting help text</p>-->
    			</div>
    		</div>
    		<div class="control-group">
    			<label class="control-label" for="ExpirationDate">Đến ngày</label>
    			<div class="controls">
                            <input type="text" data-datepicker class="input-xlarge" id="ExpirationDate" name="ExpirationDate" value="<?php if ($this->reader['CardExpirationDate']) echo date('d/m/Y', $this->reader['CardExpirationDate']); ?>">    				
    				<!--<p class="help-block">Supporting help text</p>-->
    			</div>
    		</div>
    		<div class="control-group">
    			<label class="control-label" for="BlockCard">Khoá thẻ?</label>
    			<div class="controls">
    				<input type="checkbox" name="BlockCard" value="1">    				
    				<p class="help-block">Đọc giả không thể mượn sách nếu thẻ bị khoá.</p>
    			</div>
    		</div>      
    		<div class="form-actions">
    			<button type="submit" class="btn btn-primary">Chỉnh sửa thông tin thẻ</button>
    			<a class="btn" href="javascript: window.location = '<?php echo $this->config->base_path; ?>/librarian/reader'">Huỷ bỏ</a>
    			<input type="hidden" name="action" value="card" />
    		</div>		    		
		</div>
	</fieldset>
</form>

<script type="text/javascript">
    $(function(){
        $('#account-edit,  #card-edit').on('submit',function(e){
            e.preventDefault();
            $(this).ajaxSubmit({
                forceSync: true,
                dataType: 'json',
                beforeSubmit: function(){
                    
                },
                success: function(response, statusText, xhr, $form){
                    
                    if (response.status == 0)
                    {
                        Utils.Message.Error(response.message);
                    }
                    else
                    {
                        Utils.Message.Success('Đã chỉnh sửa thông tin tài khoản thành công!');
                    }
                    
                }
            });
            
            return false;			
        });
    });
</script>